//
//  JQFYCreatGroupCoverTableViewCell.m
//  JQFY
//
//  Created by jack on 2017/10/9.
//  Copyright © 2017年 yannis. All rights reserved.
//

#import "JQFYCreatGroupCoverTableViewCell.h"

@interface JQFYCreatGroupCoverTableViewCell ()

@property (nonatomic, strong)UIImageView *coverImageView;
@property (nonatomic, strong) UILabel *abortTimeLabel;

@end

@implementation JQFYCreatGroupCoverTableViewCell

#pragma mark - setter/getter

- (void)setCreatGroupModel:(JQFYCreatGroupModel *)creatGroupModel {
    if (_creatGroupModel == creatGroupModel) {
        return;
    }
    _creatGroupModel = creatGroupModel;
    _abortTimeLabel.text = creatGroupModel.abortTime.length ? creatGroupModel.abortTime : @"截止2018年1月1日之前\n创建群为测试阶段";
}

#pragma mark - override

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    _coverImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"creatGroup_header"]];
    [self.contentView addSubview:_coverImageView];
    
    UIView *abortTimeBGView = [[UIView alloc] init];
    abortTimeBGView.backgroundColor = [UIColor whiteColor];
//    [_coverImageView addSubview:abortTimeBGView];
    
    _abortTimeLabel = [[UILabel alloc] init];
    _abortTimeLabel.font = [UIFont systemFontOfSize:12 *SCAL];
    _abortTimeLabel.backgroundColor = [UIColor whiteColor];
    _abortTimeLabel.numberOfLines = 2;
    _abortTimeLabel.textAlignment = NSTextAlignmentCenter;
//    [_coverImageView addSubview:_abortTimeLabel];
    
    [_coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
//    [abortTimeBGView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.top.equalTo(_abortTimeLabel).offset(-5);
//        make.trailing.bottom.equalTo(_abortTimeLabel).offset(5);
//    }];
//    [_abortTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(_coverImageView).offset(-24);
//        make.centerX.equalTo(_coverImageView);
//        make.leading.lessThanOrEqualTo(_coverImageView).offset(10);
//        make.trailing.lessThanOrEqualTo(_coverImageView).offset(-10);
//    }];
}

+ (CGFloat)heigtForCell {
    return 755 * DH_Screen_Width / 752 ;
}

@end
